package com.projectName.www.servlet;

import com.projectName.www.service.UserService;
import com.projectName.www.service.UserServiceImpl;
import com.projectName.www.po.Dish;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/dishListServlet")
public class DishListServlet extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("utf-8");
        UserService service=new UserServiceImpl();
        List<Dish>dishs=service.findAllDishs();
        //第二步可以将list存入request狱中

        request.setAttribute("dishs",dishs);
        //第三步转发到list.jsp
        request.getRequestDispatcher("/dishlist.jsp").forward(request,response);
    }
//    private void query()


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
